package com.example.retrofit.controller;


import com.example.retrofit.api.OsChinaApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fans
 */
@Slf4j
@RestController
@RequestMapping("/osc")
public class OsChinaController {

    @Autowired
    private OsChinaApi osChinaApi;

    @GetMapping("/projects")
    public String projects() {
        String result = osChinaApi.getProjects("", "");
        log.info(result);
        return result;
    }

    @GetMapping("/project")
    public String projectsByParam(@RequestParam("type") String type, @RequestParam("widget") String widget) {
        String result = osChinaApi.getProjects(type, widget);
        log.info(result);
        return result;
    }
}
